package com.zf.zffencheng.controller.admin;

import com.zf.zffencheng.model.Result;
import com.zf.zffencheng.model.dto.AllDeviceDTO;
import com.zf.zffencheng.model.vo.DeviceVo;
import com.zf.zffencheng.service.NtDeviceService;
import com.zf.zffencheng.strategy.DeviceStrategy;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: ScanCodeController <br/>
 * Description:  <br/>
 * date: 2021/5/28 14:14<br/>
 *
 * @author william <br/>
 */
@Api(tags = "扫码添加")
@RestController
@RequestMapping("/spi/admin/scan")
public class AdminScanCodeController {
    @Autowired
    private NtDeviceService ntDeviceService;
    @ApiOperation("管理员添加牌位")
    @PostMapping("/code/paiwei")
    @ApiResponses(value = @ApiResponse(code = 201, message = "", response = DeviceVo.class))
    public Result scanCodePaiWei(@RequestBody AllDeviceDTO allDeviceDTO){
        allDeviceDTO.setDeviceType(DeviceStrategy.PAIWEI);
        DeviceVo deviceVo = ntDeviceService.create(allDeviceDTO);
        return Result.ok(deviceVo);
    }
}
